@extends('layouts.base')
@section('title', '商品列表管理')
@section('content')
    <!-- ============================================================== -->
    <!-- Container fluid  -->
    <!-- ============================================================== -->
    <div class="container-fluid">
        <!-- ============================================================== -->
        <!-- Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <div class="row page-titles">
            <div class="col-md-5 align-self-center">
                <h3 class="text-themecolor">商品管理--列表</h3>
            </div>
            <div class="col-md-7 align-self-center">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="javascript:void(0)">首页</a></li>
                    <li class="breadcrumb-item">商品列表管理</li>
                    <li class="breadcrumb-item active">商品列表</li>
                </ol>
            </div>
        </div>
        <!-- ============================================================== -->
        <!-- End Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Start Page Content -->
        <!-- ============================================================== -->
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title">商品列表</h4>
                        <h6 class="card-subtitle"></h6>
                        <div class="card-body">
                            <form method="get" action="{{ route('admin.goods.index') }}">
                                <div class="form-row">
                                    <div class="col-md-3 mb-3">
                                        <label for="validationDefault04">商品名称</label>
                                        <input type="text" name="goodsName" class="form-control" autocomplete="off" value="{{request()->goodsName}}" placeholder="商品名称">
                                    </div>
                                    <div class="col-md-3 mb-3">
                                        <label for="validationDefault04">商品编号</label>
                                        <input type="text" name="goodscode" class="form-control" autocomplete="off" value="{{request()->goodscode}}" placeholder="商品编号">
                                    </div>
                                </div>

                                <button class="btn btn-primary" type="submit">筛选</button>
                                <a href="{{ route('admin.goods.index') }}" class="btn btn-info">重置</a>
                            </form>
                            @can('admin.goods.created')
                            <a class="btn btn-success float-right" href="{{ route('admin.goods.created') }}"><i class="fas fa-plus"></i> 添加</a>
                            @endcan
                        </div>
                        <div class="table-responsive">
                        <style>.table td, .table th {padding: 0.6rem;vertical-align: top;border-top: 1px solid #dee2e6;}</style>
                            <table id="demo-foo-addrow" class="table table-bordered m-t-30 table-hover contact-list" data-paging="true" data-paging-size="7">
                                <thead>
                                    <tr style="background: #000000;">
                                        <th>序号</th>
                                        <th>商品名称</th>
                                        <th>商品图片</th>
                                        <th>商品编码</th>
                                        <th>商品分类</th>
                                        <th>商品进货价</th>
                                        <th>商品单位</th>
                                        <!-- <th>审核状态</th>
	                                    <th>审核信息</th> -->
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($result as $k=>$item)
                                        <tr>
                                            <td>{{$k+1}}</td>
                                            <!--<td><img src="{{$item->goods_image}}" alt="" style="width:50px;height:50px;"></td>-->
                                            <td>{{ $item->goods_name}}</td>
                                            <td>
                                                @if($item->goods_image)<img src="{{$item->goods_image}}" style="width:80px;height:60px;">@else暂无图片@endif
                                            </td>
                                            <td>{{ $item->goods_code}}</td>
                                            <td>@if($item->cate_name){{ $item->cate_name}}@else暂无分类 @endif</td>
                                            <!-- <td>{{ $item->cate_name}}</td> -->
                                            <td>￥{{ $item->shop_price}}</td>
                                            <td>{{ goods_unit($item->goods_unit)}}</td>
                                            <!-- <td>{{ post_pay($item->states) }}</td>
	                                        <td>{{ $item->opinion }}</td> -->
                                            <td>{{ $item->created_at}}</td>
                                            <td>{!! $item->actionButton !!}</td>
                                            <!-- <td>
                                                <a class="btn btn-success float-right" href="{{ route('admin.goods.toexamineedit', ['goods' => $item->id]) }}"><i class="fas fa-edit"></i> 图片审核</a>
                                            </td> -->
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12 col-md-4"><div class="dataTables_info" id="example_info" role="status" aria-live="polite"></div></div>
                        <div class="col-sm-12 col-md-8">
                            <div class="dataTables_paginate paging_simple_numbers" id="example_paginate">
                                {{$result->appends([
                                    'goodsName' => request()->goodsName,
                                    'goodscode' => request()->goodscode,
                                    'categoryId' => request()->categoryId
                                ])->links('layouts.pagination')}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@stop
@section('admin-js')
    
    <script type="text/javascript">		
		function del(){
        }
        $(".isDel").click(function(){
            urls = $(this).attr("actionstr");

            swal({
                title: "您确定要删除吗?",
                icon: "warning",
                buttons: ['取消', '确定'],
                dangerMode: true,
            })
                .then((willDelete) => {
                    if (willDelete) {
                        $('#deleteForm').attr('action',urls);
                        $('#deleteForm').submit();
                    } else {

                    }
                });
        })
		
	</script>

@stop

